<?php
/**
* @version 1.5.x
* @package JoomVision Project
* @email webmaster@joomvision.com
* @copyright (C) 2008 http://www.JoomVision.com. All rights reserved.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');

$user 		= &JFactory::getUser();
$db 		= &JFactory::getDBO();
$menu 		= &JSite::getMenu();
$document	= &JFactory::getDocument();
		
//..Adding Css to Header
//JHTML::_('stylesheet','jvslidecontent.css','modules/mod_jvheadline/assets/css/');
//JHTML::_('script','jvheadline.js','modules/mod_jvheadline/assets/js/');
//... These params I get from the author of Phoca Gallery, no need in this module. Leave them as default ...........
$moduleclass_sfx = $params->get( 'moduleclass_sfx', 0 );
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');

class modJVHeadLineHelper
{
    function createdDirThumb($comp='com_content',$folderImage=''){
      $thumbImgParentFolder = JPATH_BASE.DS.'images'.DS.'stories'.DS.'thumbs'.DS.$comp.$folderImage;
      if(!JFolder::exists($thumbImgParentFolder)){
        JFolder::create($thumbImgParentFolder);
      }
    }   
	function grabData($source_to_grab, $delimiter_start, $delimiter_stop, $str_to_replace='', $str_replace='', $extra_data='')
	{
		$result='';
		$fd = "";
		$start_pos = $end_pos = 0;
		$source_to_grab = $source_to_grab;
		while(true)
		{
			if($end_pos > $start_pos)
			{
				$result = substr($fd, $start_pos, $end_pos-$start_pos);
				$result .= $delimiter_stop;
				break;
			}//10
			$data = @fread($source_to_grab, 8192);
			//echo $data;
			if(strlen($data) == 0) break;
			$fd .= $data;
			if(!$start_pos) $start_pos = strpos($fd, $delimiter_start);
			if($start_pos) $end_pos = strpos(substr($fd, $start_pos), $delimiter_stop) + $start_pos;
		}
		//echo $result;
		return str_replace($str_to_replace, $str_replace, $extra_data.$result);
	}

	function getSlideContent(&$params)
	{
		global $mainframe;

		$db			=& JFactory::getDBO();
		$user		=& JFactory::getUser();
		$userId		= (int) $user->get('id');
        
		$intro_lenght = intval($params->get( 'intro_lenght', 200) );
		$count		= (int) $params->get('count', 0);
		$catid		= trim( $params->get('catid') );
		$secid		= trim( $params->get('secid') );
		$show_front	= $params->get('show_front', 1);
		$aid		= $user->get('aid', 0);
        $categories = ( array )$params->get('categories',array());
        if(count($categories)){
          $strCatId = implode(',',$categories); 
          $categoriesCondi = " AND cc.id IN ($strCatId)";
        }          
		$showthumb	= $params->get('showthumb');
		$thumbsize	= $params->get('thumbsize');
		$htmltag	= $params->get('htmltag');

		$contentConfig = &JComponentHelper::getParams( 'com_content' );
		$access		= !$contentConfig->get('shownoauth');

		$nullDate	= $db->getNullDate();

		$date =& JFactory::getDate();
		$now = $date->toMySQL();

		$where		= 'a.state = 1'
			. ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'
			. ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'
			;

		// User Filter
		switch ($params->get( 'user_id' ))
		{
			case 'by_me':
				$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
				break;
			case 'not_me':
				$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
				break;
		}

		// Ordering
		$ordering		= 'a.id DESC';

		if ($catid)
		{
			$ids = explode( ',', $catid );
			JArrayHelper::toInteger( $ids );
			$catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
		}
		if ($secid)
		{
			$ids = explode( ',', $secid );
			JArrayHelper::toInteger( $ids );
			$secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
		}
		$show_readmore_link = false;
		$catidcount = count(explode( ',', $catid ));
		$secidcount = count(explode( ',', $secid ));
		if (($catidcount==1) && ($secidcount==1)) {
			$show_readmore_link = true;
		}
		$params->set('show_readmore_link', $show_readmore_link);
		// Content Items only
		$query = 'SELECT a.*,a.id as key1, cc.id as key2, cc.title as cat_title, ' .
			' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
			' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
			' FROM #__content AS a' .
			($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') .
			' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
			' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
			' WHERE '. $where .' AND s.id > 0' .
			($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
			((count($categories)) ? $categoriesCondi : '').			
			($show_front == '0' ? ' AND f.content_id IS NULL ' : '').
			' AND s.published = 1' .
			' AND cc.published = 1' .
			' ORDER BY '. $ordering;
		$db->setQuery($query, 0, $count);
		$rows = $db->loadObjectList();

		$i		= 0;
		$lists	= array();
		$article_count = count($rows);
		foreach ( $rows as $row )
		{
			if($showthumb) {
				$imageurl = modJVHeadLineHelper::checkImage($row->introtext);
				if(modJVHeadLineHelper::FileExists($imageurl)) {
					$lists[$i]->title = $row->title;
					$lists[$i]->alias = $row->alias;
					$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
					$lists[$i]->introtext = modJVHeadLineHelper::introContent($row->introtext, $intro_lenght, $htmltag);
					$lists[$i]->thumb = modJVHeadLineHelper::getThumb($row->introtext, '_headline', $thumbsize);
					$image_size = modJVHeadLineHelper::getImageSizes($lists[$i]->thumb);
					if($image_size[0] != $thumbsize) {
						@unlink($lists[$i]->thumb);
						$lists[$i]->thumb = modJVHeadLineHelper::getThumb($row->introtext, '_headline', $thumbsize);
					}
					if(!modJVHeadLineHelper::FileExists($lists[$i]->thumb))
						$lists[$i]->thumb_diff = $imageurl;
					$i++;
				} elseif(modJVHeadLineHelper::FileDifferentExists($imageurl)) {
					$lists[$i]->title = $row->title;
					$lists[$i]->alias = $row->alias;
					$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
					$lists[$i]->introtext = modJVHeadLineHelper::introContent($row->introtext, $intro_lenght, $htmltag);
					$lists[$i]->thumb_diff = $imageurl;
					$i++;
				}
			} else {
				$lists[$i]->title = $row->title;
				$lists[$i]->alias = $row->alias;
				$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
				$lists[$i]->introtext = modJVHeadLineHelper::introContent($row->introtext, $intro_lenght, $htmltag);

				$imageurl = modJVHeadLineHelper::checkImage($row->introtext);
				if($imageurl) {
					if(modJVHeadLineHelper::FileExists($imageurl)) {
						$lists[$i]->thumb = modJVHeadLineHelper::getThumb($row->introtext, '_headline', $thumbsize);
						$image_size = modJVHeadLineHelper::getImageSizes($lists[$i]->thumb);
						if($image_size[0] != $thumbsize) {
							@unlink($lists[$i]->thumb);
							$lists[$i]->thumb = modJVHeadLineHelper::getThumb($row->introtext, '_headline', $thumbsize);
						}
						if(!modJVHeadLineHelper::FileExists($lists[$i]->thumb))
							$lists[$i]->thumb_diff = $imageurl;
						$i++;
					} elseif(modJVHeadLineHelper::FileDifferentExists($imageurl)) {
						$lists[$i]->thumb_diff = $imageurl;
					}
				}
				$i++;
			}
		}
		return $lists;
	}

	function getImageSizes($file) {	
		return getimagesize($file);
	}

    function checkImage($file) {
		preg_match("/\<img.+?src=\"(.+?)\".+?\/>/", $file, $matches);		
        if(count($matches)){
          return $matches[1];
        } else {return '';}
	}

	function FileExists($file) {
		if(file_exists($file))
			return true;
		else
			return false;
	}

	function FileDifferentExists($file) {
		$check = @fopen($file, "r");
		if(strpos($check, "Resource id") !== false)
			return true;
		else
			return false;
	}

	function getThumb($text, $extraname, $size, $reflections=false) {       
		preg_match("/\<img.+?src=\"(.+?)\".+?\/>/", $text, $matches);
		$paths = array();
		$showbug = true;
		if (isset($matches[1])) {		   
			$image_path = $matches[1];

			//joomla 1.5 only
			$full_url = JURI::base();
			
			//remove any protocol/site info from the image path
			$parsed_url = parse_url($full_url);
			
			$paths[] = $full_url;
			if (isset($parsed_url['path']) && $parsed_url['path'] != "/") $paths[] = $parsed_url['path'];
			
			
			foreach ($paths as $path) {
				if (strpos($image_path,$path) !== false) {
					$image_path = substr($image_path,strpos($image_path, $path)+strlen($path));
				}
			}					
			// remove any / that begins the path
			if (substr($image_path, 0 , 1) == '/') $image_path = substr($image_path, 1);
			//if after removing the uri, still has protocol then the image
			//is remote and we don't support thumbs for external images
			if (strpos($image_path,'http://') !== false ||
				strpos($image_path,'https://') !== false) {
				return false;
			}
			// create a thumb filename			
			$file_div = strrpos($image_path,'.');
			$thumb_ext = substr($image_path, $file_div);
			$thumb_prev = substr($image_path, 0, $file_div);			    
			$thumb_path =  $thumb_prev . $extraname . $thumb_ext;						
			// check to see if this file exists, if so we don't need to create it
			if (function_exists("gd_info") && !file_exists($thumb_path)) {			
				// file doens't exist, so create it and save it				
				include_once('thumbnail.inc.php');
				$thumb = new ThumbnailHeadline($image_path);
				if ($thumb->error) { 
					if ($showbug)	echo "JV Image ERROR: " . $thumb->errmsg . ": " . $image_path; 
					return false;
				}
				$thumb->resize($size);				
				if ($reflections) {
					$thumb->createReflection(30,30,60,false);
				}
				if (!is_writable(dirname($thumb_path))) {
					$thumb->destruct();
					return false;
				}
				$thumb->save($thumb_path);
				$thumb->destruct();
			} 
			return ($thumb_path);
		} else {
			return false;
		}
	}
    function getThumbByNotStyleDefault($text, $extraname, $size, $reflections=false,$id=0,$isSmall = 1){
    preg_match("/\<img.+?src=\"(.+?)\".+?\/>/", $text, $matches);
        $paths = array();
        $showbug = true;
        if (isset($matches[1])) {          
            $image_path = $matches[1];

            //joomla 1.5 only
            $full_url = JURI::base();
            
            //remove any protocol/site info from the image path
            $parsed_url = parse_url($full_url);
            
            $paths[] = $full_url;
            if (isset($parsed_url['path']) && $parsed_url['path'] != "/") $paths[] = $parsed_url['path'];
            
            
            foreach ($paths as $path) {
                if (strpos($image_path,$path) !== false) {
                    $image_path = substr($image_path,strpos($image_path, $path)+strlen($path));
                }
            }           
            // remove any / that begins the path
            if (substr($image_path, 0 , 1) == '/') $image_path = substr($image_path, 1);
            //if after removing the uri, still has protocol then the image
            //is remote and we don't support thumbs for external images
            if (strpos($image_path,'http://') !== false ||
                strpos($image_path,'https://') !== false) {
                return false;
            }
            // create a thumb filename           
            $file_div = strrpos($image_path,'.');
            $thumb_ext = substr($image_path, $file_div);
            $thumb_prev = substr($image_path, 0, $file_div);            
            //$thumb_path =  $thumb_prev . $extraname . $thumb_ext;    
            //$filePath = pathinfo($image_path);
            include_once('thumbnail.inc.php');
            $thumbTmp = new ThumbnailHeadline($image_path);
            if ($thumbTmp->error) { 
                if ($showbug)   echo "JV Image ERROR: " . $thumb->errmsg . ": " . $image_path; 
                return false;
            }
            $thumbTmp->resize($size);
            $thumbWidth = $thumbTmp->currentDimensions['width'];           
            $thumbHeight = $thumbTmp->currentDimensions['height']; 
            $thumbTmp->destruct();   
            $pathInfo = pathinfo($image_path);
            //$thumb_path = J.'stories'.DS.'thumb'.DS.$id.DS.'thumb_'.$thumbWidth.'x'.$thumbHeight.$thumb_ext; 
            if($isSmall == 1){
                $thumb_path = 'images/stories/thumbs/com_content/'.$id.'/thumbs_'.$thumbWidth.'x'.$thumbHeight.$thumb_ext;
            } else {
                 $thumb_path = 'images/stories/thumbs/com_content/'.$id.'/thumbl_'.$thumbWidth.'x'.$thumbHeight.$thumb_ext;
            }                                      
            // check to see if this file exists, if so we don't need to create it
            if (function_exists("gd_info") && !file_exists($thumb_path)) {          
                // file doens't exist, so create it and save it             
                include_once('thumbnail.inc.php');
                $thumb = new ThumbnailHeadline($image_path);
                if ($thumb->error) { 
                    if ($showbug)   echo "JV Image ERROR: " . $thumb->errmsg . ": " . $image_path; 
                    return false;
                }
                $thumb->resize($size);              
                if ($reflections) {
                    $thumb->createReflection(30,30,60,false);
                }
                if (!is_writable(dirname($thumb_path))) {                 
                    $thumb->destruct();
                    return false;
                }                
                $thumb->save($thumb_path);
                $thumb->destruct();
            } 
            return ($thumb_path);
        } else {
            return false;
        }
    }
	function introContent( $text, $length=200, $htmltag=0 ) {
		$text = preg_replace( "'<script[^>]*>.*?</script>'si", "", $text );
		$text = preg_replace( '/{.+?}/', '', $text);
		if($htmltag)
			$text = strip_tags(preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text ),'<a><strong><span><small>');
		else
			$text = strip_tags(preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text ));
		if (strlen($text) > $length) {
			$text = substr($text, 0, strpos($text, ' ', $length)) . "..." ;
		} 
		return $text;
	}
}
class modJVHeadlineSmoothHelper{
function getSlideContent(&$params)
    {
        global $mainframe;

        $db         =& JFactory::getDBO();
        $user       =& JFactory::getUser();
        $userId     = (int) $user->get('id');

        $intro_lenght = intval($params->get( 'intro_lenght', 200) );
        $count      = (int) $params->get('count', 0);
        $catid      = trim( $params->get('catid') );
        $secid      = trim( $params->get('secid') );       
        $aid        = $user->get('aid', 0);
        $categories = ( array )$params->get('categories',array());
        if(count($categories)){
          $strCatId = implode(',',$categories); 
          $categoriesCondi = " AND cc.id IN ($strCatId)";
        }      
        $showthumb  = $params->get('showthumb');
        $thumbsize  = $params->get('thumbsize');
        $htmltag    = $params->get('htmltag');

        $contentConfig = &JComponentHelper::getParams( 'com_content' );
        $access     = !$contentConfig->get('shownoauth');

        $nullDate   = $db->getNullDate();

        $date =& JFactory::getDate();
        $now = $date->toMySQL();

        $where      = 'a.state = 1'
            . ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'
            . ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'
            ;       

        // Ordering
        $ordering       = 'a.id DESC';

        if ($catid)
        {
            $ids = explode( ',', $catid );
            JArrayHelper::toInteger( $ids );
            $catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
        }
        if ($secid)
        {
            $ids = explode( ',', $secid );
            JArrayHelper::toInteger( $ids );
            $secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
        }
        $show_readmore_link = false;
        $catidcount = count(explode( ',', $catid ));
        $secidcount = count(explode( ',', $secid ));
        if (($catidcount==1) && ($secidcount==1)) {
            $show_readmore_link = true;
        }
        $params->set('show_readmore_link', $show_readmore_link);
        // Content Items only
        $query = 'SELECT a.*,a.id as key1, cc.id as key2, cc.title as cat_title, ' .
            ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
            ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
            ' FROM #__content AS a' .           
            ' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
            ' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
            ' WHERE '. $where .' AND s.id > 0' .
            ($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
            
            (count($categories) ? $categoriesCondi:'').          
            ' AND s.published = 1' .
            ' AND cc.published = 1' .
            ' ORDER BY '. $ordering;
        $db->setQuery($query, 0, $count);
        $rows = $db->loadObjectList();

        $i      = 0;
        $lists  = array();
        $article_count = count($rows);
        foreach ( $rows as $row )
        {            
            $lists[$i]->title = $row->title;
            $lists[$i]->alias = $row->alias;
            $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
            $lists[$i]->introtext = modJVHeadLineHelper::introContent($row->introtext, $intro_lenght, $htmltag);
            $imageurl = modJVHeadLineHelper::checkImage($row->introtext);            
            $lists[$i]->path = $imageurl;          
            $i++;        
        }       
        return $lists;
    }
}
class modJVHeadlineHoriHelper{
  function getSlideContent($params){
    global $mainframe;       
        $db         =& JFactory::getDBO();
        $user       =& JFactory::getUser();
        $userId     = (int) $user->get('id');
        
        $categories = ( array )$params->get('categories',array());
        if(count($categories)){
          $strCatId = implode(',',$categories); 
          $categoriesCondi = " AND cc.id IN ($strCatId)";
        }      
        $intro_lenght = intval($params->get( 'intro_lenght', 200) );
        $count      = (int) $params->get('count', 0);
        $catid      = trim( $params->get('catid') );
        $secid      = trim( $params->get('secid') );        
        $aid        = $user->get('aid', 0);       
        $thumbssize  = $params->get('thumbsize');
        $thumblsize = $params->get('large_thumbsize');
        $htmltag    = $params->get('htmltag');

        $contentConfig = &JComponentHelper::getParams( 'com_content' );
        $access     = !$contentConfig->get('shownoauth');

        $nullDate   = $db->getNullDate();

        $date =& JFactory::getDate();
        $now = $date->toMySQL();

        $where      = 'a.state = 1'
            . ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'
            . ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'
            ;
        // Ordering
        $ordering       = 'a.id DESC';

        if ($catid)
        {
            $ids = explode( ',', $catid );
            JArrayHelper::toInteger( $ids );
            $catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
        }
        if ($secid)
        {
            $ids = explode( ',', $secid );
            JArrayHelper::toInteger( $ids );
            $secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
        }
        $show_readmore_link = false;
        $catidcount = count(explode( ',', $catid ));
        $secidcount = count(explode( ',', $secid ));
        if (($catidcount==1) && ($secidcount==1)) {
            $show_readmore_link = true;
        }
        $params->set('show_readmore_link', $show_readmore_link);
        // Content Items only
        $query = 'SELECT a.*,a.id as key1, cc.id as key2, cc.title as cat_title, ' .
            ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
            ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
            ' FROM #__content AS a' .             
            ' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
            ' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
            ' WHERE '. $where .' AND s.id > 0' .
            ($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
            (count($categories) ? $categoriesCondi:'').         
            ' AND s.published = 1' .
            ' AND cc.published = 1' .
            ' ORDER BY '. $ordering;
        $db->setQuery($query, 0, $count);
        $rows = $db->loadObjectList();      
        $i      = 0;
        $lists  = array();       
        $article_count = count($rows);       
        modJVHeadLineHelper::createdDirThumb(); 
        foreach ( $rows as $row )
        {            
                $imageurl = modJVHeadLineHelper::checkImage($row->introtext);
                $folderImg = DS.$row->id;
                modJVHeadLineHelper::createdDirThumb('com_content',$folderImg);                
                if(modJVHeadLineHelper::FileExists($imageurl)) {                                   
                    $lists[$i]->title = $row->title;
                    $lists[$i]->alias = $row->alias;
                    $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
                    $lists[$i]->introtext = modJVHeadLineHelper::introContent($row->introtext, $intro_lenght, $htmltag);
                    $lists[$i]->thumbs = modJVHeadLineHelper::getThumbByNotStyleDefault($row->introtext, '_headline', $thumbssize,false,$row->id);
                    $lists[$i]->thumbl = modJVHeadLineHelper::getThumbByNotStyleDefault($row->introtext, '_headline', $thumblsize,false,$row->id,0);                                      
                    $images_size = modJVHeadLineHelper::getImageSizes($lists[$i]->thumbs);                    
                    $imagel_size = modJVHeadLineHelper::getImageSizes($lists[$i]->thumbl);                   
                    if($images_size[0] != $thumbssize) {                      
                        @unlink($lists[$i]->thumbs);
                        $lists[$i]->thumbs = modJVHeadLineHelper::getThumbByNotStyleDefault($row->introtext, '_headline', $thumbssize,false,$row->id);
                    }
                    if($imagel_size[0] !=$thumblsize){
                         @unlink($lists[$i]->thumbl);
                         $lists[$i]->thumbl = modJVHeadLineHelper::getThumbByNotStyleDefault($row->introtext, '_headline', $thumblsize,false,$row->id,0);
                    }
                    if(!modJVHeadLineHelper::FileExists($lists[$i]->thumbs))
                        $lists[$i]->thumb_diff = $imageurl;
                    $i++;
                } else {                 
                    $lists[$i]->title = $row->title;
                    $lists[$i]->alias = $row->alias;
                    $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
                    $lists[$i]->introtext = modJVHeadLineHelper::introContent($row->introtext, $intro_lenght, $htmltag);
                    $lists[$i]->thumb_diff = $imageurl;
                    $lists[$i]->thumbs = '';
                    $lists[$i]->thumbl = '';
                    $i++;
                }            
         }       
        return $lists;
  }
}
?>